
#ifndef BLOCK_H_
#define BLOCK_H_

class Block {
protected:
	int textureIndex;
public:
	int blockID;

	Block(int i, int j) {
		blockID = i;
		textureIndex = j;
	}

	virtual ~Block() {
	}

	virtual int getTextureFrom(int i) const {
		return textureIndex;
	}
};

class BlockGrass : public Block {
public:
	BlockGrass(int i, int j): Block(i, j) {
	}

	virtual ~BlockGrass() {
	}

	virtual int getTextureFrom(int i) const {
		if(i == 2) return 2;
		if(i == 3) return 0;
		return Block::getTextureFrom(i);
	}
};

class BlockWood : public Block {
public:
	BlockWood(int i, int j): Block(i, j) {
	}

	virtual ~BlockWood() {
	}

	virtual int getTextureFrom(int i) const {
		if(i == 2 || i == 3) return 21;
		return Block::getTextureFrom(i);
	}
};

class BlockLeaves : public Block {
public:
	BlockLeaves(int i, int j): Block(i, j) {
	}

	virtual ~BlockLeaves() {
	}
};

Block select (0, 21);
Block stone (1, 1);
BlockGrass grass (2, 3);
Block dirt (3, 2);
Block cobblestone (4, 16);
Block planks (5, 4);
BlockWood wood (6, 20);
BlockLeaves leaves (7, 52);
Block ore_coal (8, 34);
Block ore_iron (9, 33);
Block ore_gold (10, 32);
Block sand (11, 18);
Block gravel (12, 19);
Block bedrock (13, 17);


Block* getBlockWith(int id) {
	switch(id) {
	case 1:
		return &stone;
	case 2:
		return &grass;
	case 3:
		return &dirt;
	case 4:
		return &cobblestone;
	case 5:
		return &planks;
	case 6:
		return &wood;
	case 7:
		return &leaves;
	case 8:
		return &ore_coal;
	case 9:
		return &ore_iron;
	case 10:
		return &ore_gold;
	case 11:
		return &sand;
	case 12:
		return &gravel;
	case 13:
		return &bedrock;
	default:
		return 0;
	}
}

#endif /* BLOCK_H_ */
